#!/usr/bin/perl
use strict;
use 5.010;
my @a;my $line;open(IN,"Target.txt");@a=<IN>;
my $count=0;my $pos = 0;
foreach my $tmp (@a){
my $len;
my $replacement= " " x $len;
        while($tmp =~ m/(\/\/.*)\s/){
         $pos = index( $tmp, $1);
        say "comments ","coments"," ",$count," ",$pos;
        $tmp =~ s/\/\/.*/ /;
    }
        while($tmp =~ m/([\{\}\(\)\;])/){
         $pos = index( $tmp, $1);
        say "delimiters ",$1," ",$count," ",$pos;
        $tmp =~ s/[\{\}\(\)\;]/ /;
    }
    while($tmp =~ m/(\bint|real|if|else|then|while\b)/){
            $len = length $1;
            $replacement= " " x $len;
         
            $pos = index( $tmp, $1);
        say "keywords ",$1," ",$count," ",$pos;
        $tmp =~ s/\bint|real|if|else|then|while\b/\Q$replacement\E/;
        $tmp =~ s/\\//g;
    }
    
    while ($tmp =~ m/(\b([a-zA-Z][0-9a-zA-Z]*)\b)/) {
            $len = length($1);
            $replacement= " " x $len;
         
            $pos = index( $tmp, $1);
        say "identifiers ",$1," ",$count," ",$pos;
        $tmp =~ s/\b([a-zA-Z][0-9a-zA-Z]*)\b/\Q$replacement\E/;
        $tmp =~ s/\\//g;
    }
        while ($tmp =~ m/([0-9]+\.[0-9]+(E[\+\-]?[0-9]+)?)/) {
        $len = length($1);$replacement= " " x $len;
         $pos = index( $tmp, $1);
        say "realnumbers ",$1," ",$count," ",$pos;
        $tmp =~ s/([0-9]+\.[0-9]+(E[\+\-][0-9]+)?)/\Q$replacement\E/;
        $tmp =~ s/\\//g;
    }
        while ($tmp =~ m/([0-9]+E[\+\-]?[0-9]+)/) {
        $len = length($1);$replacement= " " x $len;
         $pos = index( $tmp, $1);
        say "realnumbers ",$1," ",$count," ",$pos;
        $tmp =~ s/([0-9]+E[\+\-]?[0-9]+)/\Q$replacement\E/;
        $tmp =~ s/\\//g;
    }
        while ($tmp =~ m/(E[\+\-]?[0-9]+)/) {
        $len = length($1); $replacement= " " x $len;
         $pos = index( $tmp, $1);
        say "exponents ",$1," ",$count," ",$pos;
        $tmp =~ s/(E[\+\-]?[0-9]+)/\Q$replacement\E/;
        $tmp =~ s/\\//g;
    }
        while ($tmp =~ m/(\.[0-9]+)/) {
        $len = length($1);$replacement= " " x $len;
         $pos = index( $tmp, $1);
        say "fractions ",$1," ",$count," ",$pos;
        $tmp =~ s/(\.[0-9]+)/\Q$replacement\E/;
        $tmp =~ s/\\//g;
    }
        while ($tmp =~ m/([0-9]+)/) {
        $len = length($1);$replacement= " " x $len;
         $pos = index( $tmp, $1);
        say "intnumbers ",$1," ",$count," ",$pos;
        $tmp =~ s/([0-9]+)/\Q$replacement\E/;
        $tmp =~ s/\\//g;
    }
        while ($tmp =~ m/(==|<=|>=|!=)/) {
         $pos = index( $tmp, $1);
        say "operators ",$1," ",$count," ",$pos;
        $tmp =~ s/==|<=|>=|!=/  /;
    }
        while ($tmp =~ m/([\+\-\=\/\*\>\<])/) {
         
            $pos = index( $tmp, $1);
            say "operators ",$1," ",$count," ",$pos;
        $tmp =~ s/[\+\-\=\/\*\>\<]/ /;
    }
        
        
    chomp($tmp);
    $tmp =~ s/^\s+//;
    $tmp =~ s/\s+$//;
    my @errors = split(/[\s]+/,$tmp);
    foreach my $error(@errors) {
        
        if (!($error =~ m/[ ]+/)) {
            say "errors ",$error," ",$count;
        }
    }
    $count++;
}
